import { createApp, defineAsyncComponent } from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import '@/assets/styles/rest.scss';
import 'element-plus/dist/index.css';
import 'nprogress/nprogress.css';
import createVersionPolling from '@/utils/checkVersion';

const app = createApp(App);

const modules = import.meta.glob('@/components/**/index.vue');
// import Map from '@/views/map/index.vue';
import Three from '@/views/three/index.vue';

for (const path in modules) {
	const name = path.replace(/^.*\/components\//, '').split('/')[0];
	const component = defineAsyncComponent(modules[path]);
	app.component(name, component);
}

// app.component('Map', Map);
app.component('Three', Three);
app.use(router);
app.use(store);
app.mount('#app');
console.log(import.meta.env);

import.meta.env.MODE != 'dev' &&
	createVersionPolling({
		onUpdated: () => {
			console.log('有新版本，正在刷新页面');
		},
	});
